package org.smr.ministore.micro.client;

import org.blade.utils.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.entities.GoodsType;
import org.smr.ministore.entities.vo.Assign2OrgansVO;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import feign.hystrix.FallbackFactory;


@Component
public class HystrixGoodsTypeClientFactory implements FallbackFactory<FeignGoodsTypeMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixGoodsTypeClientFactory.class);

    @Override
    public FeignGoodsTypeMicroServiceClient create(Throwable cause) {
        HystrixGoodsTypeClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new FeignGoodsTypeMicroServiceClient() {

            @Override
            public int batchSave(List<GoodsType> entities) {
                return -1;
            }

            @Override
            public int batchModify(List<GoodsType> entities) {
                return -1;
            }

            @Override
            public int save(GoodsType entity) {
                return -1;
            }

            @Override
            public int updateById(GoodsType id) {
                return -1;
            }

            @Override
            public GoodsType queryById(Long id) {
                GoodsType goodsType = new GoodsType();
                goodsType.setId(-1L);
                return goodsType;
            }

            @Override
            public int deleteById(Long id) {
                return -1;
            }

            @Override
            public Pager<GoodsType> paginate(GoodsType entity, Long pageSize, Long pageNum) {
                Pager<GoodsType> pager = new Pager<GoodsType>();
                pager.setTotalCount(-1L);
                return pager;
            }

            @Override
            public List<GoodsType> getGoodsTypeTree(GoodsType goodsType) {
                return Collections.EMPTY_LIST;
            }

            @Override
            public int assignToOrgans(Assign2OrgansVO assign2Organs) {
                return -1;
            }

        };//Return end
    }
}